import {BaseApi} from '/@/api-services/apis/baseApi'
import { SysUser, UserAddInput, UserUpdateInput,ChangePwdInput,  UserRoleInput,SysOrg,RoleSelectorOutput } from '/@/api-services/models/system'
import { ExcelImportResult } from '/@/api-services/models/system'
import { BaseIdInput } from '/@/api-services/models/base-id-input'

/**
 * 用户管理Api
 */
class SysUserApi extends BaseApi<SysUser, UserAddInput, UserUpdateInput> {

   //批量导入
   batchImport=async(data:FormData)=>{
      return this.normalPost<ExcelImportResult>(`/batchImport`,data)
   }
   //模板下载
   templateDownload=async()=>{
      return this.normalGetBlob(`/templateDownload`,null)
   }
   errorFileDownload=async(data:BaseIdInput)=>{
      return this.normalGetBlob(`/errorDownload`,data)
   }
   //重置密码
   resetPassword=async(data:BaseIdInput)=>{
      return this.normalPost(`/resetPassword`,data)
   }
   //修改密码
   changePassword=async(data:ChangePwdInput)=>{
      return this.normalPost(`/changePassword`,data)
   }
   //改变用户状态
   changeStatus =async(data:BaseIdInput)=>{
      return this.normalPost(`/changeStatus`,data)
   }
   //授权
   grantRole=async(data:UserRoleInput)=>{
      return this.normalPost(`/grantRole`,data)
   }
   //获取组织列表树
   orgTree=async()=>{
      return this.normalGet<Array<SysOrg>>(`/orgTree`,null)
   }
   //用户已授权角色列表
   roleList=async(id:object)=>{
      return this.normalGet<Array<RoleSelectorOutput>>(`/roleList`,id)
   }
}

export default new SysUserApi('/system/user');